#include<iostream>
using namespace std;
const int N = 25;
int arr[N];
int n, k;
int flag[N];
int dis[N];
int count1;
int sum;
bool Prime(int n)
{
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			return 0;
		}
	}
	return 1;
}
void dfs(int step,int last)
{
	if (step == k) {
		if (Prime(sum)) {
			/*for (int i = 0; i < k; i++) {
				cout << dis[i] << " ";
			}
			cout << endl;*/
			count1++;
		}
		return;
	}
	for (int i = last; i < n; i++) {
		if (!flag[i]) {
			dis[step] = i;
			sum += arr[i];
			flag[i] = 1;
			dfs(step + 1, i + 1);
			sum -= arr[i];
			flag[i] = 0;
		}
	}
}
int main()
{
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	dfs(0,0);	
	cout << count1  << endl;
	return 0;
}